<template>
	<view class="container">
		<uni-forms ref="form" :rules="{}">
			<uni-forms-item label="" telephone="">
				<uni-easyinput v-model="user.telephone" placeholder="电话号码" />
			</uni-forms-item>
			<uni-forms-item label="" name="">
				<uni-easyinput type="password" v-model="user.password" placeholder="请输入密码" />
			</uni-forms-item>
			<uni-forms-item label="" confirmPassword="">
				<uni-easyinput type="password" v-model="user.confirmPassword" placeholder="再次输入密码"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item label="" name="">
				<button type="primary" @click="login">注册</button>
			</uni-forms-item>
		</uni-forms>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {
					telephone: '',
					password: '',
					confirmPassword: '',
				}
			}
		},
		methods: {
			login(e) {
			uni.request({
				url: 'http://localhost:8090/foodapp/user/register',
				method: 'POST',
				data: this.user,
				success: res => {
					console.log(res);
					if(res.data.success==true){
						uni.showToast({
							title:'注册成功'
						});
					}else{
						uni.showToast({
							title:'失败',
							icon:'none'
						});
					}
				},
				fail: () => {
					uni.showToast({
						title:'失败',
						icon:'none'
					});
				},
				complete: () => {}
			});
			}
		},
	}
</script>


<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>